﻿<?xml version="1.0" encoding="utf-8" ?>
<Batch 
    xmlns="http://schemas.dbshell.com/core"
    xmlns:rds="http://schemas.dbshell.com/datasync"
    >
    <rds:SyncModel >
        <rds:SyncModel.Sources>
            <rds:Source DataSource="{Table Continent}" Alias="src_continent">
                <rds:SourceColumn Name="ContinentId" IsKey="True" />
                <rds:SourceColumn Name="ContinentName" />
            </rds:Source>
            <rds:Source DataSource="{Table Country}">
                <rds:SourceColumn Name="CountryId" IsKey="True" />
                <rds:SourceColumn Name="CountryCode" />
                <rds:SourceColumn Name="CountryName"  />
                <rds:SourceColumn Name="ContinentId"  />
            </rds:Source>
            <rds:Source DataSource="{Table City}">
                <rds:SourceColumn Name="CityId" IsKey="True" />
                <rds:SourceColumn Name="CityName" />
                <rds:SourceColumn Name="CountryId"  />
                <rds:SourceColumn Name="CityCitizens" />
            </rds:Source>
            <rds:Source DataSource="{Table CityPart}">
                <rds:SourceColumn Name="CityPartId" IsKey="True" />
                <rds:SourceColumn Name="CityPartName" />
                <rds:SourceColumn Name="CityId"  />
            </rds:Source>
        </rds:SyncModel.Sources>

        <rds:SyncModel.Targets>
            <rds:Target TableName="TargetCityParts">
                <rds:TargetColumn Name="ContinentName" Source="ContinentName" />
                <rds:TargetColumn Name="CityPartIdOriginal" Source="CityPartId"  IsKey="True"/>
                <rds:TargetColumn Name="CityPartName" Source="CityPartName" />
                <rds:TargetColumn Name="InfoData" Expression="'' + {CityPartName} + ' ' + {CityName}" />
                <rds:TargetColumn Name="IsImported" Value="1" IsRestriction="True" />
            </rds:Target>

            <!--
            <rds:Target TableName="TargetContinents" >
                <rds:TargetColumn Name="ContinentName" Source="ContinentName" IsKey="True" />
            </rds:Target>
            -->

            <!--
            <rds:Target TableName="TargetContinentList">
                <rds:TargetColumn Name="Name" Source="ContinentName" IsKey="True"/>
            </rds:Target>
            -->

            <!--
            <rds:Target TableName="TargetCityPartByContinentList">
                <rds:TargetColumn Name="Name" Source="CityPartName" IsKey="True"/>

                <rds:Target.References>
                    <rds:TargetReference Target="TargetContinentList">
                        <rds:TargetReferenceColumn BaseName="ID_CONTINENT" RefName="ID" />
                    </rds:TargetReference>
                </rds:Target.References>
            </rds:Target>
            -->

            <!--
            <rds:Target TableName="TargetCountryList">
                <rds:TargetColumn Name="Name" Source="CountryName" IsKey="True"/>

                <rds:Target.References>
                    <rds:TargetReference Target="TargetContinentList" IsKey="True">
                        <rds:TargetReferenceColumn BaseName="ID_CONTINENT" RefName="ID" />
                    </rds:TargetReference>
                </rds:Target.References>
            </rds:Target>

            <rds:Target TableName="TargetCityList">
                <rds:TargetColumn Name="Name" Source="CityName" IsKey="True"/>

                <rds:Target.References>
                    <rds:TargetReference Target="TargetCountryList" IsKey="True">
                        <rds:TargetReferenceColumn BaseName="ID_COUNTRY" RefName="ID" />
                    </rds:TargetReference>
                </rds:Target.References>
            </rds:Target>

            <rds:Target TableName="TargetCityPartList">
                <rds:TargetColumn Name="Name" Source="CityPartName" IsKey="True"/>

                <rds:Target.References>
                    <rds:TargetReference Target="TargetCityList" IsKey="True">
                        <rds:TargetReferenceColumn BaseName="ID_CITY" RefName="ID" />
                    </rds:TargetReference>
                </rds:Target.References>
            </rds:Target>
            -->

        </rds:SyncModel.Targets>
    </rds:SyncModel>
    
    <rds:CreateProcedure ProcName="RunSync1" />
    <rds:CreateProcedure ProcName="RunSync2" />

    <rds:Run />
    <rds:Run />
</Batch>
